package com.imonsoft.sqm.vo.sys;

import java.util.List;

import javax.servlet.http.HttpSession;

import com.imonsoft.common.constant.CCommon;
import com.imonsoft.common.util.ContextUtil;
import com.imonsoft.sqm.pojo.sys.Function;
import com.imonsoft.sqm.pojo.sys.User;

/**
 * 
 * @author LiQianHui
 * @date 2013-6-7
 * @version 2013
 */
public class UserUntil extends User {
	private static final long serialVersionUID = 23489323841735808L;
	private List<Function> functionList;// 权限树

	private String passwordConfirm;

	public static UserUntil getUser() {
		HttpSession httpSession = ContextUtil.getSession();
		if (httpSession != null) {
			return (UserUntil) httpSession.getAttribute(CCommon.USER_INFO);
		}
		UserUntil userUntil = new UserUntil();
		userUntil.setId(1l);
		return userUntil;
	}

	public static void putUser2Session(UserUntil userUntil) {
		if (userUntil == null) {
			return;
		}
		HttpSession httpSession = ContextUtil.getSession();
		if (httpSession == null) {
			return;
		}
		userUntil.setPassword(null);
		httpSession.setAttribute(CCommon.USER_INFO, userUntil);
	}

	/**
	 * 判断是否已经登陆
	 */
	public static boolean isLogin() {
		return getUser() != null;
	}

	/**
	 * 没登陆
	 * 
	 * @return
	 */
	public static boolean isNotLogin() {
		return getUser() == null;
	}

	public String getPasswordConfirm() {
		return passwordConfirm;
	}

	public void setPasswordConfirm(String passwordConfirm) {
		this.passwordConfirm = passwordConfirm;
	}

	public List<Function> getFunctionList() {
		return functionList;
	}

	public void setFunctionList(List<Function> functionList) {
		this.functionList = functionList;
	}
}
